package com.zhh.springcloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RefreshScope  // 让配置变量支持动态更新，例如下面的config变量
@RequestMapping("/config")
public class NacosConfigController {

    @Value("${cv:default}")  //对应的前端的配置变量名和初始值
    private String config;  //存储前端的配置变量

    @RequestMapping("/getvalue")
    public String getvalue(){
        return this.config;  //读取配置变量
    }
}
